package com.yoomiito.app.utils

import com.yoomiito.app.R

/**
 * 数据处理
 */
object DataUtils {

    //根据类型获取相应图标
    fun ivType(type: String?) =
            when (type) {
                "淘宝" -> R.mipmap.tb
                "天猫" -> R.mipmap.tmall
                "聚划算" -> R.mipmap.juhuasuan
                "航旅" -> R.mipmap.feizhu
                "天猫国际" -> R.mipmap.tmall_guoji
                "京东"->R.drawable.icon_jd
                else -> -1
            }

    fun ivType(type: Int): Int =
            when (type) {
                0 -> R.drawable.icon_taobao
                1 -> R.drawable.icon_tmall
                else -> -1
            }

    fun storeType(type: Int): Int =
            when (type) {
                0 -> R.drawable.taobao_big
                1 -> R.drawable.tmall_big
                else -> -1
            }

    fun getGoodsType(goodsType: Int, productType: Int) =
            when (goodsType) {
                Type.ServiceConfigGoodsType.GoodsMainTypeTaoBao -> Type.GoodsType.TaoBao
                Type.ServiceConfigGoodsType.GoodsMainTypePrivateGoods -> {
                    when (productType) {
                        Type.ServiceConfigGoodsType.GoodsSmallTypeGiftGoods, Type.ServiceConfigGoodsType.GoodsSmallTypeBigGiftGoods -> Type.GoodsType.Gift
                        Type.ServiceConfigGoodsType.GoodsSmallTypeBaoPinGoods -> Type.GoodsType.BaoPin
                        Type.ServiceConfigGoodsType.GoodsSmallTypeYouPinGoods -> Type.GoodsType.YouPin
                        Type.ServiceConfigGoodsType.GoodsSmallTypeSubjectGoods -> Type.GoodsType.College
                        Type.ServiceConfigGoodsType.GoodsSmallTypeStarStoreGoods -> Type.GoodsType.StarStore
                        Type.ServiceConfigGoodsType.GoodsSmallTypeSongDuoduoVipGoods->Type.GoodsType.GiveMore
                        Type.ServiceConfigGoodsType.GoodsSmallTypeSongDuoduoFreeGoods->Type.GoodsType.FreeGift
                        else -> -1
                    }
                }
                else -> -1
            }

    fun getGoodsType(goodsType: String):Int{
        return when(goodsType){
            "1"-> Type.GoodsType.TaoBao
            "2"-> Type.GoodsType.Gift
            "3"-> Type.GoodsType.BaoPin
            "4"-> Type.GoodsType.YouPin
            "5"-> Type.GoodsType.AgentMall
            else-> -1
        }
    }

//    fun youPinPrice(price:String,oldPrice:String,userYouMi:String,deductionYouMi:String):String{
//        return if (!App.mAppConfig.isLogin || userYouMi.isEmptyOr0() || deductionYouMi.isEmptyOr0()){
//            if (oldPrice.isEmptyOr0()) "¥$price " else "¥$price ¥$oldPrice"
//        }else{
//            "¥$price +$deductionYouMi"
//        }
//    }
}